Skip to content

KAFKA-20120: Create HeadersSerializer and HeadersDeserializer#21401

Open
frankvicky wants to merge 3 commits intoapache:trunkfrom
frankvicky:KAFKA-20120
Open

KAFKA-20120: Create HeadersSerializer and HeadersDeserializer#21401
frankvicky wants to merge 3 commits intoapache:trunkfrom
frankvicky:KAFKA-20120

Conversation

@frankvicky
Copy link
Contributor

@frankvicky frankvicky commented Feb 4, 2026

JIRA: KAFKA-20120
This PR aims to add HeadersSerializer and HeadersDeserializer as
infrastructure of KIP-1271.

@github-actions github-actions bot added triage PRs from the community streams labels Feb 4, 2026
@frankvicky frankvicky requested a review from mjsax February 4, 2026 13:57
@mjsax mjsax added kip Requires or implements a KIP and removed triage PRs from the community labels Feb 4, 2026
Copy link
Contributor

@aliehsaeedii aliehsaeedii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @frankvicky for the PR. LGTM. Just some suggestions!

final DataOutputStream out = new DataOutputStream(baos)) {

final Header[] headerArray = (headers == null) ? new Header[0] : headers.toArray();
ByteUtils.writeVarint(headerArray.length, out);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we should always use ByteUtils apis and we should know that it uses zig-zag encoding from.

try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final DataOutputStream out = new DataOutputStream(baos)) {

final Header[] headerArray = (headers == null) ? new Header[0] : headers.toArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(headers == null || !headers.iterator().hasNext())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lean to keep the current code style since it is more straightforward.
WDYT?

}

final ByteBuffer buffer = ByteBuffer.wrap(data);
final int headerCount = ByteUtils.readVarint(buffer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var name headersCount?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kip Requires or implements a KIP streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants